package com.lanou3g.bookstore.category.web.servlet;

import com.lanou3g.bookstore.category.domain.Category;
import com.lanou3g.bookstore.category.service.CategoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "CategoryServlet", urlPatterns = "/class.do")
public class CategoryServlet extends HttpServlet {
    private CategoryService service = new CategoryService();

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Category> bookClass = service.findAll();
        request.setAttribute("bookClass", bookClass);
        request.getRequestDispatcher("/jsps/left.jsp")
                .forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
